function take<T>(arr:T[],n:number):T[]{
    if(n>=arr.length){
        return arr
    }
    else{
        const  newArray:T[] = [];
        for (let index = 0; index < n; index++) {
            const element = arr[index];
            newArray.push(element)
            
        }
        return newArray
    }

}
const newArray = take<string>(["2","3","4","5"],2);
console.log(newArray)
type callback<T>= (n:T,i:number)=>boolean
function filter<T>(arr:T[],callback:callback<T>):T[]{
    const newArray:T[] = []
   arr.forEach((element,index) => {
     if(callback(element,index)){
        return newArray.push(element)
     }
   });
   return newArray
}
const arr= [0,1,2,3,2]

const filterArr  = filter(arr,(item,index)=>{return item%2 ==0})
console.log(filterArr)